package com.itqf.service.impl;

import com.itqf.bean.DtsGoodsAttribute;
import com.itqf.bean.DtsGoodsAttributeExample;
import com.itqf.mapper.DtsGoodsAttributeMapper;
import com.itqf.service.DtsGoodsAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * projectName: gp_manage
 *
 * @author: 赵伟风
 * time: 2021/8/23 23:27
 * description:
 */
@Service
public class DtsGoodsAttributeServiceImpl implements DtsGoodsAttributeService {

    @Autowired
    private DtsGoodsAttributeMapper dtsGoodsAttributeMapper;
    /**
     * 根据商品id查询参数
     *
     * @param id
     * @return
     */
    @Override
    public List<DtsGoodsAttribute> findAttributeByGid(Integer id) {

        DtsGoodsAttributeExample example = new DtsGoodsAttributeExample();
        DtsGoodsAttributeExample.Criteria criteria = example.createCriteria();

        criteria.andDeletedEqualTo(false);
        criteria.andGoodsIdEqualTo(id);

        List<DtsGoodsAttribute> goodsAttributes = dtsGoodsAttributeMapper.selectByExample(example);

        return goodsAttributes;
    }

    @Override
    public void deleteByGid(Integer gid) {

        DtsGoodsAttributeExample example = new DtsGoodsAttributeExample();
        example.createCriteria().andGoodsIdEqualTo(gid);

        dtsGoodsAttributeMapper.deleteByExample(example);
    }

    @Override
    public void add(DtsGoodsAttribute attribute) {
        dtsGoodsAttributeMapper.insertSelective(attribute);
    }
}
